<import file="block/common.html" name="url" :tpl_cfg="['urlName'=>$title,'backList'=>'返回列表']"/>
<div class="layui-fluid">
    <div class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label required">角色</label>
            <div class="layui-input-inline">
					<select name="gid" lay-verify="required" lay-reqtext="角色不能为空">
					<?php foreach ($groupList as $key=>$vo){?>
					  <option value="<{$vo['id']}>" <?php if(!empty($info) && $info['gid'] == $vo['id']){echo "selected";} ?>><{$vo['groupname']}></option>
					<?php }?>   
					</select>  
			</div>
        </div>
		<div class="layui-form-item">
            <label class="layui-form-label required">用户登录名</label>
            <div class="layui-input-inline">
                <input type="text" name="username" lay-verify="required" lay-reqtext="用户登录名不能为空" placeholder="请输入用户登录名"
                 value="<{$info['username']??''}>" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">必须为 字母或者 字母和数字组合</div>
        </div>
		<div class="layui-form-item">
            <label class="layui-form-label required">真实姓名</label>
            <div class="layui-input-inline">
                <input type="text" name="nickname" lay-verify="required" lay-reqtext="昵称不能为空" placeholder="请输入昵称" value="<{$info['nickname']??''}>" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">联系手机</label>
            <div class="layui-input-inline">
                <input type="text" name="phone" lay-verify="required" lay-reqtext="联系手机不能为空" placeholder="请输入联系手机" value="<{$info['phone']??''}>" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">头像</label>
            <div class="layui-input-inline" style="width:420px;" id="photopre">
                <?php if(!empty($info['photo'])){ ?>
                    <img src="<{$info['photo']??''}>" width="150" height="150"  class="layui-circle"  >
                <?php }else{ ?>
                    <i class="layui-icon layui-icon-friends  layui-circle" style="font-size: 80px; color: #1E9FFF;"></i>
                <?php } ?>   
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required"></label>
            <div class="layui-input-inline" style="width:420px;">
                <?php if(SysRolCk("upload_upload")){ ?>
                <input type="text" id="imageval" name="photo" value="<{$info['photo']??''}>" class="layui-input">
                <button type="button" class="layui-btn" id="thumimg">
                  <i class="layui-icon">&#xe67c;</i>上传头像
                </button>
                <?php } ?>
                <button type="button" class="layui-btn" id="defaltimg">
                    <i class="layui-icon">&#xe64a;</i>系统默认
                  </button>
            </div>
            <div class="layui-form-mid layui-word-aux">200X200px</div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-inline">
		     	<input type="text" name="password" value="" class="layui-input">			
            </div>
            <div class="layui-form-mid layui-word-aux">不修改密码可以为空</div>
        </div>
		<div class="layui-form-item">
			<label class="layui-form-label">状态</label>
			<div class="layui-input-inline">
			  <input type="radio" name="status" value="1" title="启用" <?php if(!empty($info) && $info["status"] ==1){ echo 'checked=""';} ?>>
			  <input type="radio" name="status" value="0" title="禁用" <?php if(!empty($info) && $info["status"] ==0){ echo 'checked=""';} ?>>
			</div>
		  </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
			<input type="hidden" name="id" value="<{$infoId}>">
            <?php if($infoId==1){ ?>                 
                <button class="layui-btn layui-btn-disabled">创始帐户不能在这里修改</button>
                <?php }else{ ?> 
                <button class="layui-btn" lay-submit lay-filter="saveBtn" ><i class="layui-icon">&#x1005;</i><?php echo lang('save');?></button>                
            <?php } ?>               
            </div>
        </div>
    </div>
</div>
<script>
    layui.define(function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            upload = layui.upload,
            $ = layui.$;
        form.render();

        var uploadInst = upload.render({
			elem: '#thumimg' //绑定元素
			,url: '<{CAUrl("upload","upload")}>&up=img&profilePhoto'
			,size: 1000
			,accept:'images'
			,acceptMime: 'image/*'
			,acceptMime: 'image/jpg, image/png,image/jpeg'
			,done: function(res){
				if(res.status == 1){
					$.post("<{CAUrl('upload','upload')}>&up=img&del", { url: "<{$info['photo']??''}>"});//删除旧文件
					$('#imageval').val(res.result[0].src);
                    $('#photopre').html('<img src="'+res.result[0].src+'" width="150" height="150"  class="layui-circle"  >');
					layer.msg(res.info);
				}else{
					layer.msg(res.info);
				}
			}
			,error: function(){
			  //请求异常回调
			}
		});

        $("#defaltimg").click(function(){
            $('#photopre').html('<i class="layui-icon layui-icon-friends  layui-circle" style="font-size: 80px; color: #1E9FFF;"></i> ');
            $('#imageval').val("");
        });

        //监听提交
        form.on('submit(saveBtn)', function (data) {
			$.post('<{CAUrl("adminuser",ROUTE["act"])}>',data.field,function(res){
                if(res.status == 1){
                    layer.msg(res.info, {icon: 1, time: 1000},function(){
						loadMain('<{CAUrl("adminuser","index")}>');
					});
                }else{
                    layer.msg(res.info, {icon: 2, anim: 6, time: 5000});
                }
            });
            return false;
        });

    });
</script>